package guice.boot.archive.container.registry;

import guice.boot.archive.spi.registry.ServiceMetaData;
import guice.boot.archive.spi.registry.ServiceReference;


public class ServiceReferenceImpl<T> implements ServiceReference<T> {

    private ServiceMetaData serviceMetadata;

    private T serviceObject;

    public ServiceReferenceImpl(ServiceMetaData serviceMetadata, T serviceObject) {
        this.serviceMetadata = serviceMetadata;
        this.serviceObject = serviceObject;
    }

    @Override
    public T getServiceObject() {
        return serviceObject;
    }

    @Override
    public ServiceMetaData getServiceMetaData() {
        return serviceMetadata;
    }

    @Override
    public int getPriority() {
        return getServiceMetaData().getServiceProvider().getPriority();
    }

    @Override
    public int hashCode() {
        return serviceMetadata.hashCode();
    }

    @Override
    public String toString() {
        return serviceMetadata.toString();
    }
}